const util = require("../../utils/config.js");
//获取应用实例
const app = getApp()
const http_host = util.http_host;
const agent_id = util.agent_id;
const img_url = util.img_url;
const appId = util.appId;
const secret = util.secret;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title: '附近商家',
    nearShop: [{
      img: 'http://e.yizhizaibo.cn/addons/wxz_wzbagent/public/upload/1.jpg',
      name: '断桥餐馆',
      mode: '营业',
      price: '30',
      list: '月售59单',
      distance: '8.6km',
      status: '无需排队',
      grade: 'five-star',
      address: "浙江省杭州市西湖区西湖路666号"
    }, {
      img: 'http://e.yizhizaibo.cn/addons/wxz_wzbagent/public/upload/1.jpg',
      name: '苏堤餐馆',
      mode: '营业',
      price: '30',
      list: '月售59单',
      distance: '8.6km',
      status: '无需排队',
      grade: 'four-star',
      address: "浙江省杭州市西湖区西湖路555号"

    }, {
      img: 'http://e.yizhizaibo.cn/addons/wxz_wzbagent/public/upload/1.jpg',
      name: '雷峰塔餐馆',
      mode: '休息中',
      price: '128',
      list: '月售59单',
      distance: '8.6km',
      status: '无需排队',
      grade: 'one-star',
      address: "浙江省杭州市西湖区西湖路233号"
    }, {
      img: 'http://e.yizhizaibo.cn/addons/wxz_wzbagent/public/upload/1.jpg',
      name: '三潭餐馆',
      mode: '休息中',
      price: '128',
      list: '月售59单',
      distance: '8.6km',
      status: '无需排队',
      grade: 'one-star',
      address: "浙江省杭州市西湖区西湖路233号"
    },
    {
      img: 'http://e.yizhizaibo.cn/addons/wxz_wzbagent/public/upload/1.jpg',
      name: '平湖餐馆',
      mode: '休息中',
      price: '128',
      list: '月售59单',
      distance: '8.6km',
      status: '无需排队',
      grade: 'one-star',
      address: "浙江省杭州市西湖区西湖路233号"
    }
    ],
    //附近商家
    orderShop:'',
    // 图片链接
    ImgUrl:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function onLoad(e) {
    var that=this;

      wx.setNavigationBarTitle({
        title: '预约取号'
      });
      // this.setData({
      //   title: '预约订座'
      // });
      // 获取到与预约区号的商家
      var openId = app.globalData.openId;
      wx.request({
        url: http_host + 'getBeforedistance',
        data: {
          agent_id: agent_id,
          openId: openId,
          order: 'data'
        },
        header: {
          'Content-Type': 'application/json'
        },
        success: function (res) {
          that.setData({
            orderShop:res.data,
            ImgUrl: img_url
          })
        }
      })
    // TODO: onLoad
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function onReady() {
    // TODO: onReady
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function onShow() {
    // TODO: onShow
  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function onHide() {
    // TODO: onHide
  },


  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function onUnload() {
    // TODO: onUnload
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '微信小程序',
      desc: '预约取号',
      path: '/pages/user?id=123'
    }
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function onPullDownRefresh() {
    // TODO: onPullDownRefresh
  }
});